package com.king.spark.rdd.transform

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
 * @Author wdl
 * @Date 2022/11/22 16:34
 */
object Spark_RDD_glom {

  def main(args: Array[String]): Unit = {


    val sparkConf = new SparkConf().setMaster("local[*]").setAppName("WordCount")

    val sparkContext: SparkContext = new SparkContext(sparkConf)

    val dataRDD : RDD[Int] = sparkContext.makeRDD(List(
      1,2,3,4
    ),2)

    val dataRDD1:RDD[Array[Int]] = dataRDD.glom()

    dataRDD1.foreach(x => println( x.mkString(",")))

    val value: RDD[Int] = dataRDD1.map(_.max)

    println(value.sum())

    sparkContext.stop()
  }
}
